package main

import "fmt"

func main() {
	fmt.Println(checkString("123", "321"))   //true
	fmt.Println(checkString("1231", "3121")) //true
	fmt.Println(checkString("1231", "3123")) //false
	fmt.Println(checkString("1231", "312"))  //false
}

func checkString(s1, s2 string) bool {
	if len(s1) != len(s2) {
		return false
	}
	m := make(map[rune]int32)
	for _, v := range s1 {
		m[v]++
	}

	for _, v := range s2 {
		if m[v] == 0 {
			return false
		}
		m[v]--
	}

	return true
}
